home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: netcom.com!mikenann
- From: Michael Glassman and Ann Ross <mikenann@netcom.com>
- Subject: Re: Can you overload a constructor?
- Content-Type: text/plain; charset=us-ascii
- Message-ID: <3147CDA4.71BC@netcom.com>
- Sender: mikenann@netcom21.netcom.com
- Content-Transfer-Encoding: 7bit
- Organization: NETCOM On-line Communication Services (408 261-4700 guest)
- References: <Do859K.K9B@watserv3.uwaterloo.ca>
- Mime-Version: 1.0
- Date: Thu, 14 Mar 1996 07:41:24 GMT
- X-Mailer: Mozilla 2.0 (Win16; I)
-
- jfournie@sciborg.uwaterloo.ca wrote:
- >
- > Greetings,
- >
- > I am new to C++ and just wanted to make sure it
- > was OK to overload a constructor. gnu c++
- > doesn't have a problem with it, but is it normally
- > done?
- >
-
- Absolutely. Overloaded constructors are often desired.
- Consider a string class, String. We may want the following constructors:
-
- String( ); // A constructor with no arguments.
- // Creates an empty String.
- String( const char* const ); // Creates a String from a
- //C-style string.
- String( const String& ); // Creates a copy of another String.
- // Also known as the copy contructor.
- String( const int ); // Creates a String from an integer.
-
- Michael Glassman
-